//测试放到这里，不然有点太麻烦了
import java.util.LinkedList;
import edu.princeton.cs.algs4.In;
import edu.princeton.cs.algs4.Point2D;
import edu.princeton.cs.algs4.RectHV;
import edu.princeton.cs.algs4.StdDraw;
import edu.princeton.cs.algs4.StdOut;
public class App {
 public static void main(String[] args) {
    //测试用数据
    RectHV rectTest = new RectHV(0.61, 0.08, 0.89, 0.17);

    In in = new In("input.txt");
        PointSET brute = new PointSET();
        KdTree kdtree = new KdTree();
        while (!in.isEmpty()) {
        double x = in.readDouble();
        double y = in.readDouble();
        Point2D p = new Point2D(x, y);
        kdtree.insert(p);
        brute.insert(p);
        }

        RectHV rect = new RectHV(0.0, 0.0, 1.0, 1.0);
        rect.draw();
        kdtree.draw();
        //测试
        Point2D p=new Point2D(0.81, 0.42);
        StdDraw.setPenColor(StdDraw.BLUE);
        StdDraw.circle(0.81, 0.42, 0.05);
        Point2D myp=kdtree.nearest(p);
        StdDraw.setPenColor(StdDraw.BLACK);
        StdDraw.circle(myp.x(), myp.y(), 0.3);
        for(Point2D point2d:kdtree.range(rect))
        {
            point2d.draw();
        }
        int fff=0;

 }
}
